/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package ysw.action;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;
import ysw.vo.*;
import ysw.jdbc.*;
import org.apache.struts2.ServletActionContext;
import java.sql.SQLException;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletResponse;
/**
 *
 * @author Administrator
 */
public class IncomeAction extends ActionSupport{
    /**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	/**
	 * 
	 */

	private Income income;
    public Income getIncome(){
        return income;
    }
    public void setIncome(Income income){
        this.income=income;
    }
    private List<Income> incomeList;
    public String execute() throws Exception{
        IncomeJdbc incomeJ=new IncomeJdbc();
        income.setInid(income.getInid());
        income.setInmoney(income.getInmoney());
        income.setIntime(income.getIntime());
        income.setIntype(income.getIntype());
        incomeJ.addIncome(income);
        return SUCCESS;
    }
    
@SuppressWarnings("unchecked")
public String showAllIncome() throws Exception{
        @SuppressWarnings("unused")
		Income income=new Income();
        IncomeJdbc incomeJ=new IncomeJdbc();
        try{
            incomeList=incomeJ.showIncome();
        }catch(SQLException e){
            e.printStackTrace();
        }
        @SuppressWarnings("rawtypes")
		Map request=(Map)ActionContext.getContext().get("request");
        request.put("incomeList",incomeList);
        return SUCCESS;
    }
public String deleteIncome()throws Exception{
    Income income=new Income();
    IncomeJdbc incomeJ=new IncomeJdbc();
    incomeJ.deleteIncome(income.getInid());
    System.out.println(income.getInid()+"income.getInid()");
    return SUCCESS;
    
}
@SuppressWarnings("unchecked")
public String showOneIncome() throws Exception{
    Income income1=new Income();
    IncomeJdbc incomeJ=new IncomeJdbc();
    income1=incomeJ.showOneIncome(income.getInid());
@SuppressWarnings("rawtypes")
Map request=(Map)ActionContext.getContext().get("request");
request.put("income1",income1);
return SUCCESS;


}
public String updateSaveIncome() throws Exception{
    IncomeJdbc incomeJ=new IncomeJdbc();
   
    income.setInid(income.getInid());
 
    income.setInmoney(income.getInmoney());
    income.setIntime(income.getIntime());
    income.setIntype(income.getIntype());
    incomeJ.updateSaveIncome(income);
    return SUCCESS;
}

}
